package com.boc.news.beans;

import java.io.UnsupportedEncodingException;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

public class EncodForMap {
	/**
	 * 将一个ISO-8859-1编码转换成一个UTF-8编码
	 * @param m
	 * @return
	 * @throws UnsupportedEncodingException
	 */
	public static Map encodingUTF8(Map m) throws UnsupportedEncodingException {
		Map map = new HashMap();
		Iterator it = m.entrySet().iterator();     
		while (it.hasNext()) {     
			Map.Entry entry = (Map.Entry)it.next();     
			Object key = entry.getKey();     
			Object value = entry.getValue(); 
			if(value != null) {
				value = new String(value.toString().getBytes("ISO-8859-1"), "UTF-8");
			}
			map.put(key, value);
		}   
		return map;
	}
}
